package com.easylinkin.linkappapi.childinspection.controller;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.easylinkin.linkappapi.childinspection.entity.InspectionPointEntity;
import com.easylinkin.linkappapi.childinspection.service.InspectionPointService;
import com.easylinkin.linkappapi.childinspection.vo.BaseVo;
import com.easylinkin.linkappapi.childinspection.vo.InspectionPointVo;
import com.easylinkin.linkappapi.common.model.RequestModel;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;

/**
 * @author linWenLe
 * @Date: 2024/3/27
 * @Description: 巡检点管理
 */
@RestController
@RequestMapping("/inspectionPoint")
public class InspectionPointController extends ApiController {

    @Resource
    private InspectionPointService inspectionPointService;

    /***
     * 巡检点列表
     * @return
     */
    @RequestMapping("getInspectionPointList")
    public RestMessage getInspectionPointList(@RequestBody RequestModel<InspectionPointVo> restPage) {
        return  RestBuilders.successBuilder(inspectionPointService.getInspectionPointList(restPage)).build();
    }

    /***
     * 生成巡检点编号
     * @return
     */
    @RequestMapping("createPointCode")
    public RestMessage createPointCode() {
        return  RestBuilders.successBuilder(inspectionPointService.createPointCode()).build();
    }

    /***
     * 新增巡检点
     * @return
     */
    @RequestMapping("insertPoint")
    public RestMessage insertPoint(@RequestBody InspectionPointVo entity) {
        inspectionPointService.insertPoint(entity);
        return  RestBuilders.successBuilder().message("新增成功").build();
    }

    /***
     * 修改巡检点
     * @return
     */
    @RequestMapping("updatePoint")
    public RestMessage updatePoint(@RequestBody InspectionPointEntity entity) {
        inspectionPointService.updatePoint(entity);
        return  RestBuilders.successBuilder().message("修改成功").build();
    }

    /***
     * 删除巡检点
     * @return
     */
    @RequestMapping("deletePoint")
    public RestMessage deletePoint(String id) {
        inspectionPointService.deletePoint(id);
        return  RestBuilders.successBuilder().message("删除成功").build();
    }

    /***
     * 巡检点详情
     * @return
     */
    @RequestMapping("pointInfo")
    public RestMessage pointInfo(String id) {
        return  RestBuilders.successBuilder(inspectionPointService.pointInfo(id)).build();
    }

    /***
     * 巡检点记录详情
     * @return
     */
    @RequestMapping("pointRecordInfo")
    public RestMessage pointRecordInfo(@RequestBody RequestModel<BaseVo> restPage) {
        return  RestBuilders.successBuilder(inspectionPointService.pointRecordInfo(restPage)).build();
    }

    /***
     * 查询今日已巡检记录
     * @return
     */
    @RequestMapping("todayRecordInfo")
    public RestMessage todayRecordInfo(@RequestBody RequestModel<BaseVo> restPage) {
        return  RestBuilders.successBuilder(inspectionPointService.todayRecordInfo(restPage)).build();
    }

    /***
     * 巡检点整改信息
     * @return
     */
    @RequestMapping("rectificationInfo")
    public RestMessage rectificationInfo(String recordId) {
        return  RestBuilders.successBuilder(inspectionPointService.rectificationInfo(recordId)).build();
    }
}
